import format from '@dfeidao/atom-web/dt/format';
import get from '@dfeidao/atom-web/global/get';
import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
import p002 from './p002';
import p003 from './p003';
import p004 from './p004';

interface Par extends Event {
	page_no: number;
}
export default async function a001(fd: IFeidaoAiBrowserComponent, e: Par) {
	// todo
	const no = get('staff_no');
	const res = await nodejs<{ dt: Array<{ lnventory_name: string, project_name: string,
		inventory_time: number, inventory_people: string, record_no: string }>;
		dtt: Array<{ project_name: string, project_no: string }>; c: number }>
		('inventory-of-assets/zj-000001/s002',
		{
			filter: {
				pn: e.page_no,
				staff_no: no
			}
		});
const tt = res.dt.map((n) => {
	return { ...n, inventory_time: format(n.inventory_time, 0) };
});
if (tt.length > 0) {
	render(fd, tt, p002, 'p002', 'inner');
} else {
	render(fd, "", p003, 'p003', 'inner');
}
if (res.dt.length > 20) {
	render(fd, res.dt, p004, 'p004', 'inner');
}
}
